#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
import time
import threading
import queue

q = queue.Queue(10)  # 生成10个队列


# 生产者
def productor(i):
    while True:
        q.put("厨师做了{0}号包子".format(i))
        time.sleep(2)


# 消费者
def consumer(k):
    while True:
        print("消费者{} 吃了{}".format(k, q.get()))
        time.sleep(1)


for i in range(5):
    p = threading.Thread(target=productor, args=(i,))
    p.start()

for k in range(3):
    c = threading.Thread(target=consumer, args=(k,))
    c.start()
